using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using OF.DB.DataAccess;
using OF.DB.Test.Entity;

namespace OF.DB.Test.DataAccess
{    
    public static partial class UserDao
    {
        public static int Add(User entity)
        {
            //createdate
            object result = DBHelper.ExecuteScale(AddSql, GetAddSqlParams(entity));
            return Convert.ToInt32(result);
        }

        public static void Update(User entity)
        {
            //editdate
            DBHelper.ExecuteNonQuery(UpdateSql, GetUpdateSqlParams(entity));
        }

        public static User GetByKey(int id)
        {
            return DBHelper.ExecuteReader<User>(GetByIdSql, GetGetByIdSqlParams(new User
            {
                id = id
            })).FirstOrDefault();
        }

        public static void DeleteByKey(int id)
        {
            DBHelper.ExecuteNonQuery(DeleteByIdSql, GetDeleteByIdSqlParams(new User
            {
                id = id
            }));
        }	
    }
}